<%@  page  contentType=" application/vnd.ms-excel;  charset=utf-8"%>
<% response.setHeader("Content-disposition","attachment; filename=test.xls");
%>
  <% response.setContentType("application/vnd.ms-excel;charset=GBK"); %>   

  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<style type="text/css">
td{
text-align:center
}
</style>
<script type="text/javascript"> 

function saveCode(obj) { 
          var winname = window.open('', '_blank', 'top=10000'); 
          var strHTML = document.all.tableExcel.innerHTML; 
          winname.document.open('text/html', 'replace'); 
          winname.document.writeln(strHTML); 
          winname.document.execCommand('saveas','','excel.xls'); 
          winname.close(); 
} 

</script> 

</head> 

<body> 
<div id="tableExcel" >  

	<table class="list"  asc="asc" desc="desc" >
		<thead>
			<tr>
				<th width="20%">产品编号</th>
				<th width="15%">商品名字</th>
				<th width="5%">状态</th>
				<th width="10%" align="center">当前库房</th>
				<th width="5%" align="center">数量</th>
				<th width="15%" align="center">入库时间</th>
				<th width="10%" align="center">入库流水号</th>
				<th width="10%" align="center">有效时间</th>
			</tr>
			
		</thead>
		<tbody>
			<c:forEach  items="${requestScope.u}" var="role" >

				<tr>
				<td>${role.goodsId }</td>
				<td>${role.goodsName }</td>
				<td>${role.statusName }</td>
				<td>${role.deptName }</td>
				<td>${role.sum }</td>
				<td>${role.storage_time }</td>
				<td>${role.code }</td>
				<td>${role.effective_time }</td>
			
				</tr>
				
			
			   

		</c:forEach>
		</tbody>
		
	</table>
	</div>
<input type="button" value="另存为 Excel" onclick="saveCode(tableExcel)"> 
</body> 
</html>